import keyboard


def on_key(event):
    if event.name == 'up':
        print('机器人正在前进')

    elif event.name == 'down':
        print('机器人正在后退')

    elif event.name == 'left':
        print('机器人正在左转')

    elif event.name == 'right':
        print('机器人正在右转')

keyboard.on_press(on_key)

keyboard.wait()
